package person;

import java.util.Calendar;

import model.Model;

public class Person extends Model{
	
	/**
	 * per creare una nuova persona con nuovo id assegnato automaticamente
	 * @param lastname 
	 * @param firstname
	 * @param taxCode
	 * @param address
	 * @param phoneNumber
	 * @param fax
	 * @param email
	 */
	public Person(String name, String surname, String taxCode, String address, String phoneNumber, String fax, String email) {
		super();
		this.name = name;
		this.surname = surname;
		this.taxCode = taxCode;
		this.address = address;
		this.phoneNumber = phoneNumber;
		this.fax = fax;
		this.email = email;
	}
	
	/**
	 * per creare una persona con id noto
	 * @param id
	 * @param name
	 * @param surname
	 * @param taxCode
	 * @param address
	 * @param phoneNumber
	 * @param fax
	 * @param email
	 */
	public Person(long id, String name, String surname, String taxCode, String address, String phoneNumber, String fax, String email) {
		super(id);
		this.name = name;
		this.surname = surname;
		this.taxCode = taxCode;
		this.address = address;
		this.phoneNumber = phoneNumber;
		this.fax = fax;
		this.email = email;
	}
	public Person(long id, String name, String surname, String taxCode, String address, String phoneNumber, String fax, String email,Calendar birthDate) {
		super(id);
		this.name = name;
		this.birthDate=birthDate;
		this.surname = surname;
		this.taxCode = taxCode;
		this.address = address;
		this.phoneNumber = phoneNumber;
		this.fax = fax;
		this.email = email;
	}
	public Person(String name, String surname, String taxCode, String address, String phoneNumber, String fax, String email,Calendar birthDate) {
		this(Model.NO_ID,  name,  surname,  taxCode,  address,  phoneNumber,  fax,  email, birthDate);
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}
	public String getTaxCode() {
		return taxCode;
	}
	public void setTaxCode(String taxCode) {
		this.taxCode = taxCode;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getPhoneNumber() {
		return phoneNumber;
	}
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	public String getFax() {
		return fax;
	}
	public void setFax(String fax) {
		this.fax = fax;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Override
	public boolean equals(Object o){
		if(o instanceof Person)
			return ((Person)o).getTaxCode().equalsIgnoreCase(taxCode);
		return false;
	}
	
	public boolean contains(String filter){
		String string = name +" "+ surname+" "+ taxCode +" "+ address +" "+ phoneNumber +" "+ fax +" "+ email;
		if(string.contains(filter))
			return true;
		return false;
	}
	public void setBirthDate(Calendar birthDate){
		this.birthDate=birthDate;
	}
	public Calendar getBirthDate(){
		return this.birthDate;
	}
	
	private Calendar birthDate;
	private String name;
	private String surname;
	private String taxCode;
	private String address;
	private String phoneNumber;
	private String fax;
	private String email;
}
